﻿using System;
using System.Collections.Generic;
using System.Text;
using UmlDesigner.Gui;

namespace UmlDesigner.Model.WorkUnits
{
    /// <summary>
    /// A work unit consisting of other work units.
    /// </summary>
    internal class CompositeWorkUnit : IWorkUnit
    {

        private List<IWorkUnit> items = new List<IWorkUnit>();

        internal void AddItem(IWorkUnit item)
        {
            items.Add(item);
        }

        internal void RemoveItem(IWorkUnit item)
        {
            items.Remove(item);
        }

        #region IWorkUnit Members

        public virtual void Do(UmlControl umlControl)
        {
            foreach (IWorkUnit item in items)
            {
                item.Do(umlControl);
            }
        }

        public virtual void Undo(UmlControl umlControl)
        {
            foreach (IWorkUnit item in items)
            {
                item.Undo(umlControl);
            }
        }

        #endregion
    }
}
